<?php

class sfGuardUserActions extends autoSfGuardUserActions
{

  public function executeMessageCompose (sfWebRequest $request)
  {
    $this->form = new UserMessageForm();
  }

  public function executeMessageSend (sfWebRequest $request)
  {
    $this->form = new UserMessageForm();
    $this->form->bind($request->getParameter($this->form->getName()));
    if ($this->form->isValid())
    {
      $workflow = new SimpleMessageWorkflow($this->form->getValue('subject'), $this->form->getValue('message'), $this->form->getValue('user_list'));
      $workflow->start();
      $this->getUser()
        ->setFlash(UserFlash::SUCCESS, sprintf('Nachricht erfolgreich an %s Benutzer verschickt.', count($this->form->getValue('user_list'))));
      $this->redirect('sf_guard_user');
    }
    else
    {
      $this->setTemplate('messageCompose');
    }
  }
}